#include <iostream>
#include <bits/stdc++.h>

using namespace std;

int arr[100009];

//bubblesort
void BubbleSort(int *a,int k)//fault:timelimit
{
    int tail=k;
    while(tail)
    {
        int flag=0;
        for(int i=1;i<tail;++i)
        {
            if(a[i-1]>a[i])
            {
                int tem=a[i-1];
                a[i-1]=a[i];
                a[i]=tem;
                flag=1;
            }

        }

        if(flag==0) break;

        tail--;
    }


}



//selectsort
void swap(int *a,int *b)//timelimit
{
    int tem=*a;
    *a=*b;
    *b=tem;

}
void SelectSort(int *a,int k)
{
    int head=0,tail=k-1;
    while(head<tail)
    {
        int maxi=head;
        int mini=tail;
        for(int i=head;i<=tail;++i)
        {
            if(a[i]>a[maxi]) maxi=i;
            if(a[i]<a[mini]) mini=i;

        }

        swap(&a[head],&a[mini]);

        if(maxi==head)//if maxi has been swapped,find it
        {
            maxi=mini;
        }

        swap(&a[tail],&a[maxi]);

        head++;
        tail--;

    }

}


//insertsort
void InsertSort(int *a,int n)//timelimit
{
    for(int i=0;i<n-1;++i)
    {
        int key=i;
        int tem=a[key+1];
        while(key>=0)
        {
            if(a[key]>tem)
            a[key+1]=a[key],key--;

            else break;

        }

        a[key+1]=tem;
    }
}

//ShellSort
void ShellSort(int *a,int k)
{
    int gap=k;
    while(gap>1)
    {
        gap=gap/2;
        for(int i=0;i<k-gap;++i)
        {
            int key=i;
            int tem=a[key+gap];
            while(key>=0)
            {
                if(tem<a[key])
                {
                    a[key+gap]=a[key];
                    key-=gap;
                }

                else break;
            }

            a[key+gap]=tem;
        }
    }
}

int main()
{
    int n;
    cin>>n;

    for(int i=0;i<n;++i)
    {
        cin>>arr[i];

    }

//    BubbleSort(arr,n);
//SelectSort(arr,n);
 //   InsertSort(arr,n);
    ShellSort(arr,n);

    for(int i=0;i<n;++i)
    {
        cout<<arr[i]<<" ";

    }
    return 0;
}
